package com.easy.common.check;


import com.baidu.aip.contentcensor.AipContentCensor;
import org.json.JSONObject;

import java.util.Arrays;

public class Sample {
    //设置APPID/AK/SK
    public static final String APP_ID = "28892078";
    public static final String API_KEY = "G9HNATvUP76DLZGYnRu4kltA";
    public static final String SECRET_KEY = "fuGNzqIzg6ZFpkhWIQcP7KsLlN5gGGPc";

    public static void main(String[] args) {
        long s = System.currentTimeMillis();
        // 初始化一个AipContentCensor
        AipContentCensor client = new AipContentCensor(APP_ID, API_KEY, SECRET_KEY);

        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);

        // 可选：设置代理服务器地址, http和socket二选一，或者均不设置
//        client.setHttpProxy("proxy_host", 2);  // 设置http代理
//        client.setSocketProxy("proxy_host", 1);  // 设置socket代理

        // 可选：设置log4j日志输出格式，若不设置，则使用默认配置
        // 也可以直接通过jvm启动参数设置此环境变量
        System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties");

        // 调用接口
        String path = "你马de";
        JSONObject res = client.textCensorUserDefined(path);
        System.out.println(res.toString(2));
        String s1 = res.toString();
        System.out.println(s1.contains("不合规"));
        long l = System.currentTimeMillis();
        System.out.println((l-s)/1000+"S");

    }
}
/*
*{
  "conclusion": "合规",
  "log_id": 16703923246495242,
  "isHitMd5": false,
  "conclusionType": 1
}
{"conclusion":"合规","log_id":16703923246495242,"isHitMd5":false,"conclusionType":1}
2S
*
*
* */